<template>
	<div class="weui-panel" style="height: 100%;">
		<div class="weui-panel__hd">
			<div style="display: flex;">我的钱包</div>
		</div>
		<div class="weui-panel__bd " style="height: 6.25rem;background-color: #ffc300;">
			<div class="weui-flex" style="margin: 3px 3px;height: 100%;">
				<div class="weui-flex__item myflex" @click="goCharge">
					<div class="weui-cell_access titleA">余额（元）&gt;</div>
					<div style="text-align: center;font-size: 1.2625rem;width: 50%;">{{memberInfo.moneySurplus}}</div>
				</div>
				<div class="weui-flex__item myflex">
					<div class="weui-cell_access titleA">充值总金额（元）</div>
					<div style="text-align: center;font-size: 1.2625rem; width: 50%;">{{memberInfo.moneyTotal}}</div>
				</div>
			</div>
		</div>
		<a class="weui-cell  weui-cell_access" href="javascript:">
			<div class="weui-cell__bd" style="text-align: left;">
				<p>账单</p>
			</div>
			<div class="weui-cell__ft">
			</div>
		</a>
		<div style="position: absolute;bottom: 0;width: 100%;">
			<button class="btn" @click="goBack">返回</button>
		</div>
	</div>
</template>

<script>
	import {
		getToken,
	} from '@/utils/auth'
	import apis from '@/utils/apis.js'
	import wxConst from '@/utils/wxContants.js'
	import {
		getUserInfo
	} from '@/apis/wx/weixinJs.js'
	import constant from '@/utils/constant'
	export default {

		data() {
			return {
				account: "", //用户账号
				userInfo: {}, //信息
				memberInfo: {}, //会员信息
			}
		},
		created() {
			let token = localStorage.getItem(constant.WX_TOKEN);
			this.account = JSON.parse(localStorage.getItem(token)).userInfo.wxUser.wxAccount
			this.getUserInfo(this.account);
		},
		methods: {
			/* 去充值 */
			goCharge(){
				this.$router.push({name:"recharge",params:{account:this.account}});
			},
			getUserInfo() {
				getUserInfo(apis.getUserInfo, {
					"account": this.account
				}).then(res => {
					if (res.resultCode == constant.SUCCESS && res.data) {
						this.userInfo = res.data["wxUser"];
						this.memberInfo = res.data["wxUserMember"];
						this.memberInfo["memberTypeName"] = this.getMemberTypeName(this.memberInfo.memberCurLevel);
					}

				})
			},
			goBack() {
				this.$router.go(-1);
			},
			getMemberTypeName(code) {
				let name = "";
				for (var i in wxConst.memberType) {
					if (wxConst.memberType[i].code == code) {
						name = wxConst.memberType[i].name;
						break;
					}
				}
				return name;
			},
		}
	}
</script>

<style>
	@import "../../assets/css/returnBtn.css";
	.sp {
		margin: 3px;
		width: 100%;
		height: 100%;
	}

	.myflex {
		font-size: 0.625rem;
		text-align: center;
		margin-top: 20px;
		margin-left: 20px;
	}

	.titleA {
		font-size: 0.925rem;
		text-align: center;
		margin-top: 10px;
		margin-left: 20px;
		display: flex;
	}


</style>
